/**
 * Created by huangzy on 2015/5/12.
 * 348845730@qq.com
 */
var LngLat = (function(){
	var getGeocoder = (function(){
		var myGeo = null;
		return function(){
			if(!myGeo) myGeo = new BMap.Geocoder();
			return myGeo;
		}
	})();
	function getByAddress(city,address,opt){
		var fn = new Function;
		var opt = opt || {};
		var success = opt.success || fn;
		var fail = opt.fail || fn;
		var error = opt.error || fn;
		var loading = opt.loading || fn;
		if(!address || !city){
			error("缺省地址或城市");
			return false;
		}
		loading();
		var gocoder = getGeocoder();
		gocoder.getPoint(address,function(point){
			if(point){
				success(point);
			}else{
				fail();
			}
		},city)
	}
	return{
		getByAddress : getByAddress
	}

})();